home *** CD-ROM | disk | FTP | other *** search
- Path: news.umbc.edu!not-for-mail
- From: schlein@umbc.edu (Jonas J. Schlein)
- Newsgroups: comp.lang.c
- Subject: Re: HELP! Please! Why doesn't this work
- Date: 25 Feb 1996 19:38:02 -0500
- Organization: University of Maryland Baltimore County
- Message-ID: <4gqvda$ish@umbc9.umbc.edu>
- References: <Pine.ULT.3.91a.960215131933.614A-100000@red5.cac.washington.edu> <GEORG.96Feb23192440@acds14.physik.rwth-aachen.de>
- NNTP-Posting-Host: umbc9.umbc.edu
- NNTP-Posting-User: schlein
-
- >>...
- >> solution_array = (char **) malloc(size);
-
- > This should read
- >
- > solution_array = (char**)malloc(size * sizof(char*));
-
- Actually I'd write:
-
- solution_array = malloc (size * sizeof (*solution_array));
-
- Plus I would make sure that I have supplied the <stdlib.h> library.
- This has the advantage of being correct, not having any typos (I hope),
- not relying on possibly changing data types, and not hiding possible
- errors with unnecessary casts.
- --
- "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
-
- Jonas J. Schlein (schlein@gl.umbc.edu)
-